package com.sc.nft.dto;

import com.sc.nft.enums.EcologyPoolLinkTypeEnum;
import com.sc.nft.enums.EcologyPoolOperationTypeEnum;
import com.sc.nft.enums.EcologyPoolTypeEnum;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

/**
 * @author 刘国航
 * @since 2024/8/11 14:46
 */
@Data
@Builder
public class EcologyPoolReducePointsDTO implements Serializable {
    private static final long serialVersionUID = -3307593072778385480L;

    /**
     * 数量
     */
    private BigDecimal linkCount;

    /**
     * 物质类型
     */
    private EcologyPoolLinkTypeEnum linkType;

    /**
     * 主动操作方品牌id
     */
    private Long daoId;

    /**
     * 主动操作方用户id
     */
    private Long userId;

    /**
     * 主动操作方关联id
     */
    private Long relationId;

    /**
     * 主动操作方类型
     */
    private EcologyPoolTypeEnum poolType;

    /**
     * 操作类型
     */
    private EcologyPoolOperationTypeEnum operationType;

    /**
     * 被动操作方类型
     */
    private EcologyPoolTypeEnum sourcePoolType;

    /**
     * 被动操作方品牌id
     */
    private Long sourceDaoId;

    /**
     * 被动操作方用户id
     */
    private Long sourceUserId;

    /**
     * 被动操作方关联id
     */
    private Long sourceRelationId;

    /**
     * 备注
     */
    private String remark;

    /**
     * 事务ID
     */
    private String transactionUuid;

    /**
     * 主动操作方
     */
    private String activeOperatorName;

    /**
     * 被动操作方
     */
    private String passiveOperatorName;

    /**
     * 组装唯一约束
     */
    public String buildPkCode() {
        return (Objects.nonNull(this.poolType) ? this.poolType.getCode() : "*") + "_"
                + (Objects.nonNull(this.linkType) ? this.linkType.getCode() : "*") + "_"
                + ((Objects.nonNull(this.daoId) && this.daoId > 0) ? this.daoId : "*") + "_"
                + ((Objects.nonNull(this.userId) && this.userId > 0) ? this.userId : "*") + "_"
                + ((Objects.nonNull(this.relationId) && this.relationId > 0) ? this.relationId : "*");
    }

}
